package org.raymond.iworks.study.basic.designpattern.memento;

/**
 * @author raymond
 * @version V1.0
 * @Description: TODO
 */
public class Client {
    public static void main(String[] args) {
        Originator originator = new Originator();
        Caretaker caretaker = new Caretaker();
        originator.setState("1");
        caretaker.add(originator.saveState());
        originator.setState("2");
        caretaker.add(originator.saveState());
        originator.setState("3");
        caretaker.add(originator.saveState());

        System.out.println("当前状态:"+originator.getState());

        // 将状态恢复到最开始的时候
        originator.loadState(caretaker.get(0));
        System.out.println("最初的状态:"+originator.getState());
    }
}
